//
//  SISSCalculateModel.m
//  SISSAPP
//
//  Created by 优房网 on 2017/5/15.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSCalculateModel.h"

@implementation SISSCalculateModel

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

- (instancetype)initWithDict:(NSDictionary *)dict {
    
    if (self = [super init]) {
        
        [self setValuesForKeysWithDictionary:dict];
    }
    
    return self;

}

+ (instancetype)calculateDataWithDict:(NSDictionary *)dict {
    
    return [[self alloc] initWithDict:dict];
}

#pragma mark - 加载数据
// 公积金贷款
+ (NSArray<SISSCalculateModel *>*)loadReservedFunds1Data {
    
    //获取plist
    NSURL *url = [[NSBundle mainBundle] URLForResource:@"reservedFunds1" withExtension:@"plist"];
    
    //根据plist加载数组
    NSArray *dictArr = [NSArray arrayWithContentsOfURL:url];
    
    //定义一个保存模型类的数组
    NSMutableArray *arrayM = [NSMutableArray array];
    
    //循环遍历字典数组，把每个元素转为模型类对象
    for (NSDictionary *dict in dictArr) {
        
        SISSCalculateModel *model = [SISSCalculateModel calculateDataWithDict:dict];
        
        [arrayM addObject:model];
    }
    
    return arrayM;
}

+ (NSArray<SISSCalculateModel *>*)loadReservedFunds2Data {
    
    //获取plist
    NSURL *url = [[NSBundle mainBundle] URLForResource:@"reservedFunds2" withExtension:@"plist"];
    
    //根据plist加载数组
    NSArray *dictArr = [NSArray arrayWithContentsOfURL:url];
    
    //定义一个保存模型类的数组
    NSMutableArray *arrayM = [NSMutableArray array];
    
    //循环遍历字典数组，把每个元素转为模型类对象
    for (NSDictionary *dict in dictArr) {
        
        SISSCalculateModel *model = [SISSCalculateModel calculateDataWithDict:dict];
        
        [arrayM addObject:model];
    }
    
    return arrayM;
}

// 商业贷款
+ (NSArray<SISSCalculateModel *>*)loadCommercialLoan1Data {
    
    //获取plist
    NSURL *url = [[NSBundle mainBundle] URLForResource:@"commercialLoan1" withExtension:@"plist"];
    
    //根据plist加载数组
    NSArray *dictArr = [NSArray arrayWithContentsOfURL:url];
    
    //定义一个保存模型类的数组
    NSMutableArray *arrayM = [NSMutableArray array];
    
    //循环遍历字典数组，把每个元素转为模型类对象
    for (NSDictionary *dict in dictArr) {
        
        SISSCalculateModel *model = [SISSCalculateModel calculateDataWithDict:dict];
        
        [arrayM addObject:model];
    }
    
    return arrayM;
}
+ (NSArray<SISSCalculateModel *>*)loadCommercialLoan2Data {
    
    //获取plist
    NSURL *url = [[NSBundle mainBundle] URLForResource:@"commercialLoan2" withExtension:@"plist"];
    
    //根据plist加载数组
    NSArray *dictArr = [NSArray arrayWithContentsOfURL:url];
    
    //定义一个保存模型类的数组
    NSMutableArray *arrayM = [NSMutableArray array];
    
    //循环遍历字典数组，把每个元素转为模型类对象
    for (NSDictionary *dict in dictArr) {
        
        SISSCalculateModel *model = [SISSCalculateModel calculateDataWithDict:dict];
        
        [arrayM addObject:model];
    }
    
    return arrayM;
}

// 组合贷款
+ (NSArray<SISSCalculateModel *>*)loadCombinedLoan1Data {
    
    //获取plist
    NSURL *url = [[NSBundle mainBundle] URLForResource:@"combinedLoan1" withExtension:@"plist"];
    
    //根据plist加载数组
    NSArray *dictArr = [NSArray arrayWithContentsOfURL:url];
    
    //定义一个保存模型类的数组
    NSMutableArray *arrayM = [NSMutableArray array];
    
    //循环遍历字典数组，把每个元素转为模型类对象
    for (NSDictionary *dict in dictArr) {
        
        SISSCalculateModel *model = [SISSCalculateModel calculateDataWithDict:dict];
        
        [arrayM addObject:model];
    }
    
    return arrayM;
}
+ (NSArray<SISSCalculateModel *>*)loadCombinedLoan2Data {
    
    //获取plist
    NSURL *url = [[NSBundle mainBundle] URLForResource:@"combinedLoan2" withExtension:@"plist"];
    
    //根据plist加载数组
    NSArray *dictArr = [NSArray arrayWithContentsOfURL:url];
    
    //定义一个保存模型类的数组
    NSMutableArray *arrayM = [NSMutableArray array];
    
    //循环遍历字典数组，把每个元素转为模型类对象
    for (NSDictionary *dict in dictArr) {
        
        SISSCalculateModel *model = [SISSCalculateModel calculateDataWithDict:dict];
        
        [arrayM addObject:model];
    }
    
    return arrayM;
}


@end
